package com.lagou.config;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;

/**
 * @author 郑样平
 * @date 2021/5/16  20:36
 */
public class MyWebApplicationInitializer extends MyServlet implements WebApplicationInitializer  {
    public void onStartup(ServletContext servletContext) throws ServletException {

        ServletRegistration.Dynamic registration = servletContext.addServlet("app", super.getDispatcherServlet());
        if (registration != null) {
            registration.setLoadOnStartup(1);
            registration.addMapping("/app/*");
        }
    }

}
